#include <iostream>

class NetWork
{
public:
    //定义纯虚函数
    //具有纯虚函数的类不能构建对象
    virtual void Connect() = 0;
    virtual void Read() = 0;
    virtual void Write() = 0;
};

//继承抽象类但是没有实现所有纯虚函数的类,仍然不能实例化，仍是抽象类
class TCP : public NetWork
{
public:
    void Connect()
    {
        std::cout<<"TCP连接"<<std::endl;
    }
    void Write()
    {
        std::cout<<"TCP写"<<std::endl;
    }
    void Read()
    {
        std::cout<<"TCP读"<<std::endl;
    }
};

class UDP : public NetWork
{
public:
    void Connect()
    {
        std::cout<<"UDP连接"<<std::endl;
    }
    void Write()
    {
        std::cout<<"UDP写"<<std::endl;
    }
    void Read()
    {
        std::cout<<"UDP读"<<std::endl;
    }
};

int main()
{
    //实现基类所有纯虚函数的子类可以实例化
    NetWork *n = new UDP;
    n->Connect();
    n->Read();
    n->Write();
    return 0;
}